﻿@page "/Samples/Dynamic_Content/{AuthId:int}"
@page "/Samples/Dynamic_Content"
@inject ILogger<Dynamic_Content> nlogILogger
@inject NavigationManager navigationManager
@inject SwalService SwalService
@inject ITempService ITempService
@inject IAdminService IAdminService
@using System.Data
@using BBCore.Core.Models.EnumTypes
<div style="background-color:antiquewhite">
    @if (ControlList != null)
    {
        <Row ItemsPerRow="ItemsPerRow.Six" RowType="RowType.Inline">
            @foreach (var control in ControlList)
            {

                @if (control.IsRequired)
                {
                    <div>@(control.Label)<span class="text-danger">*</span>:</div>
                }
                else
                {
                    <div>@control.Label:</div>
                }

                @switch (control.Type)
                {
                    case ControlTypeEnum.TextEdit:
                        <input @bind-value="@Values[control.Label]" class="form-control" required="@control.IsRequired" />
                        break;
                    case ControlTypeEnum.DateEdit:
                        @*  格式:Select CONVERT(varchar(100), GETDATE(), 23): 2023-05-16  *@
                        <input type="date" class="form-control" value="@Values[control.Label]" @onchange="@(a => ValueChanged(a, control.Label))" required="@control.IsRequired" />
                        break;
                    case ControlTypeEnum.Datetime_local:
                        <input type="datetime-local" class="form-control" value="@Values[control.Label]" @onchange="@(a => ValueChanged(a, control.Label))" required="@control.IsRequired" step="1" />
                        break;
                    case ControlTypeEnum.DropDownList:
                        <p>组织测试</p>
                        @* <Temp_GetOrg @bind-ORGID="@Values[control.Label]"></Temp_GetOrg> *@
                        break;
                }

            }

        </Row>
        <br />
        <div style="text-align:center">
            <Button Text="查询" IsAsync="true" class="btn btn-primary" OnClick="@OnClickAsync" />
            <button class="btn btn-danger" @onclick="ExportToExcel">导出EXCEL(数值型)</button>
            <button class="btn btn-danger" @onclick="ExportToTextExcel">导出EXCEL(文本型)</button>
        </div>

    }
    <hr />
    @* 指定Table的ID为myQueryTemptable *@
    <table id="myQueryTemptable" class="table table-bordered table-condensed table-hover" >
        <thead>
            <tr>

                @foreach (var col in Cn_columns)
                {
                    @*DataRow row in table.Rows*@
                    <th style="background-color: coral; color: #000079; font-weight: bold;">@col</th>
                }
            </tr>
        </thead>
        <tbody>
            @if (Dt.Rows.Count > 0)
            {
                @foreach (DataRow row in Dt.Rows)
                {
                    <tr>
                        @foreach (DataColumn col in Dt.Columns)
                        {
                            <td>@row[col.ColumnName]</td>
                        }
                    </tr>
                }
            }
            else
            {
                <tr>
                    <td colspan="@Cn_columns.Length" class="text-danger" style="text-align:center">无数据!</td>
                </tr>
            }
        </tbody>
    </table>
</div>